/**
 * 
 */
package com.pmsco.pms.services.impl;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.pmsco.pms.core.dao.PmsMenuDao;
import com.pmsco.pms.core.domain.PmsMenu;
import com.pmsco.pms.services.interfaces.PmsMenuService;

/**
 * @author Long Tran
 *
 */
public class PmsMenuServiceImpl implements PmsMenuService {
	private static final Logger logger = LoggerFactory.getLogger(PmsMenuServiceImpl.class);
	
	private static PmsMenuDao pmsMenuDao;
	
	public PmsMenu getMenuById(Long id) {
		return pmsMenuDao.getMenuById(id);
	}

	public PmsMenu getMenuByName(String menuName) {
		List<PmsMenu> ret = pmsMenuDao.findByProperty(PmsMenu.nameField, menuName);
		if(ret != null && ret.size() > 0)
			return ret.get(0);
		else
			return null;
	}
	
	public List<PmsMenu> listPmsMenu(PmsMenu searchTemplate) {
		return pmsMenuDao.listPmsMenu(searchTemplate);
	}
	
	/**
	 * @param pmsMenuDao the pmsMenuDao to set
	 */
	public void setPmsMenuDao(PmsMenuDao pmsMenuDao) {
		logger.info("Start setPmsMenuDao");
		logger.debug("PMS Menu Dao: " + pmsMenuDao);
		this.pmsMenuDao = pmsMenuDao;
		logger.info("End setPmsMenuDao");
	}
	
	public List<PmsMenu> listPmsMenu(String searchField, String searchString, String searchOper, String sidx, String sord, Integer page, Integer rows) {
		return pmsMenuDao.listPmsMenu(searchField, searchString, searchOper, sidx, sord, page, rows);
	}
	
	public Integer countListPmsMenu(String searchField, String searchString, String searchOper) {
		return pmsMenuDao.countListPmsMenu(searchField, searchString, searchOper);
	}

	public List<PmsMenu> findByProperty(String propertyName, Object value) {
		return pmsMenuDao.findByProperty(propertyName, value);
	}
	
	public void saveOrUpdatePmsMenu(PmsMenu pmsMenu) {
		pmsMenuDao.saveOrUpdatePmsMenu(pmsMenu);
	}
	
	public void deleteMenu(PmsMenu pmsMenu) {
		pmsMenuDao.deleteMenu(pmsMenu);
	}
}
